public class Demo {

    public static int count = 0;

    public static void main(String[] args) throws InterruptedException {

        Thread t1 = Thread.currentThread();

        Thread t = new Thread(() -> {

            for (int i = 0; i < 3; i++) {
//                count++;

                try {
                    t1.join();
                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);

                    break;
                }

                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);


                    break;
                }
            }
            System.out.println("t 线程结束");

        });

        t.setDaemon(true);

        t.start();
        System.out.println(t.isAlive());
//        t.join();
//        System.out.println(count);

        Thread.sleep(1000);
        System.out.println("main 线程结束");
        System.out.println(t.isAlive());
        t.interrupt();
        System.out.println(t.isInterrupted());
        System.out.println(t.isAlive());
    }
}
